package com.tanhua.controller;

import com.tanhua.service.BaiduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("baidu")
public class BaiduController {

    @Autowired
    private BaiduService baiduService;

    @PostMapping("/location")
    public ResponseEntity uploadLocation(@RequestBody Map map){
        //获取数据
        //维度
        Double latitude = Double.valueOf(map.get("latitude").toString());
        //经度
        Double longitude = Double.valueOf(map.get("longitude").toString());
        //地址
        String addrStr = map.get("addrStr").toString();

        //调用service
        baiduService.uploadLocation(longitude,latitude,addrStr);
        //返回
        return ResponseEntity.ok(null);

    }



}
